package com.bgs.eat.memberPrice.controller;

import com.bgs.eat.config.CommonResult;
import com.bgs.eat.memberPrice.entity.MemberPriceEntity;
import com.bgs.eat.memberPrice.service.MemberPriceService;
import com.bgs.eat.page.PageRequest;
import com.bgs.eat.page.PageResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName MemberPriceController
 * @Description TODO 会员价格管理（后端）
 * @Author G胖
 * @Date 2022-10-12 下午 02:57
 **/

@RestController
@CrossOrigin
@RequestMapping("/memberPrice")
public class MemberPriceController {

    @Resource
    MemberPriceService memberPriceService;

    /**
    * @Author G胖
    * @Description 新增会员价格（后端）
    * @Date 2022-10-12 下午 03:06
    * @Return com.bgs.eat.config.CommonResult

    */
    @PostMapping("/saveMemberPrice")
    public CommonResult saveMemberPrice(@RequestBody MemberPriceEntity memberPriceEntity){
        return CommonResult.ok(memberPriceService.saveMemberPrice(memberPriceEntity));
    }

    /**
    * @Author G胖
    * @Description 校验会员价格新增修改是否录入某个月份 （后端）
    * @Date 2022-10-12 下午 03:22
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/selectMemberDetailsMonth")
    public CommonResult selectMemberDetailsMonth(Integer month,Integer memberId){
        return CommonResult.ok(memberPriceService.selectMemberDetailsMonth(month,memberId));
    }

    /**
    * @Author G胖
    * @Description 会员价格分页全查+模糊查（会员名称）
    * @Date 2022-10-12 下午 03:38
    * @Return com.bgs.eat.page.PageResult

    */
    @GetMapping("/getMemberPriceByPage")
    public PageResult getMemberPriceByPage(PageRequest pageRequest,String memberName){
        return memberPriceService.getMemberPriceByPage(pageRequest,memberName);
    }

    /**
    * @Author G胖
    * @Description 查询会员价格（前端购买会员界面）
    * @Date 2022-10-12 下午 06:43
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getMemberPrice")
    public CommonResult getMemberPrice(Integer memberId){
        return CommonResult.ok(memberPriceService.getMemberPrice(memberId));
    }


    /**
     * @Author cjl
     * @Description 修改会员价格（后端）
     * @Date  14:47
     * @Return com.bgs.eat.config.CommonResult
     * @param memberPriceEntity
     */
    @PutMapping("/updateMemberPrice")
    public CommonResult updateMemberPrice(@RequestBody MemberPriceEntity memberPriceEntity){
        return CommonResult.ok(memberPriceService.updateMemberPrice(memberPriceEntity));
    }
}
